// 菜单管理的全部接口
import request from "@/utils/request";
import { PermisstionResponseData ,MenuParams} from "./type";

enum API{
      //获取全部菜单与按钮的标识数据
  ALLPERMISSTION_URL = '/admin/acl/permission',
  //给某一级菜单新增一个子菜单
  ADDMENU_URL = '/admin/acl/permission/save',
  //更新某一个已有的菜单
  UPDATE_URL = '/admin/acl/permission/update',
  //删除已有的菜单
  DELETEMENU_URL = '/admin/acl/permission/remove/',
}
// 获取全部菜单与按钮的标识数据
export const reqAllPermisstion=()=>request.get<any,PermisstionResponseData>(API.ALLPERMISSTION_URL);
// 更新和添加菜单
export const reqAddOrUpdateMenu=(data:MenuParams)=>{
  // 有id更新
  if(data.id){
    return request.put<any,any>(API.UPDATE_URL,data)
  }else{
    // 添加
    return request.post<any,any>(API.ADDMENU_URL,data)
  }
}
// 删除已有菜单
export const reqRemoveMenu=(id:number)=>request.delete<any,any>(API.DELETEMENU_URL+id);